[#include "/WEB-INF/pages/common/taglibs.ftl"]
	[#--设置回退地址(使用${backUrl}进行访问)--]
	[@c.url var="backUrl" value='/manage/User_list.action' scope="page"]
		[@c.param name="currentPage" value="${currentPage}"/]
	[/@c.url]
[#macro _script]
	<script type="text/javascript" src="[@c.url value='/js/custom/tables.js'/]"></script>
	<script type="text/javascript" src="[@c.url value='/js/plugins/jquery.alerts.js'/]"></script>
	<script type="text/javascript">
		var base = (function(){
			// 事件绑定
			function _addEventListeners() {
				// 维护
				$('a[act=edit]').unbind('click').click(function(){
					var id = $(this).parent().attr('tval');
					[@c.url var="editUrl" value='/manage/User_edit.action' scope="page"]
						[@c.param name="currentPage" value="${currentPage}"/]
					[/@c.url]
					var url = "${editUrl}&id=" + id;
					//$.get(url, {'id':id, 'ajax':'true'}, function(data) {
					//	$('#body').html(data);
					//})
					window.location = url;
				})
				// 删除
				$('a[act=delete]').unbind('click').click(function(){
						var	id = $(this).parent().attr('tval');
						var title = $('#delete-confirm').attr('title');
						var content = $('#delete-confirm').html();
						jConfirm(content, title, function(r) {
							if (r) {
								[@c.url	var="deleteUrl" value='/manage/User_delete.action' scope="page"]
									[@c.param name="backUrl" value="${backUrl}"/]
									[@c.param name="id" value=""/]
								[/@c.url]
								window.location	= "${deleteUrl}" + id;
							}
						});
					return false;
				})
				// 删除所有
				$('.deletebutton').click(function(){
					var tb = jQuery(this).attr('tableid');	
					var sel = false;											//initialize to false as no selected row
					var ch = jQuery('#'+tb).find('tbody input[type=checkbox]');	//get each checkbox in a table
					var content = "会员删除后将无法恢复,是否仍要删除?";
					var title = "删除所有会员";
					jConfirm(content, title, function(r) {
						if (r) {
							var _$form = $('#rmUsers');
							var index = 0;
							ch.each(function(){
								if(jQuery(this).is(':checked')) {
									sel = true;	
									var id = $(this).parents('td').attr('tval');
									$(this).parents('tr').fadeOut(function(){
										$(this).remove();							//remove row when animation is finished
									});
									_$form.append("<input type='hidden' name='userList["+index+"].id' value="+id+" />");
									index ++;
								}
							});
							if (sel) {
								_$form.submit();
							} else {
								jAlert('No data selected');
							}
						}
					});
				});
			}
			return {
                config: {
                	url : null,
                    theme: null
                },
                init: function () {
                	_addEventListeners();
                }
			}
		}());
		
		$(function(){
			var link = "[@c.url value='/manage/User_list.action?currentPage=${currentPage}' /]";
			base.config.theme = getTheme();
			base.config.url = link;
            //Initializing the form
			base.init();
		})
	</script>
[/#macro]
[#if piece==true]
	[@_script /]
	<!--设置提交行为-->
	[#assign act="save" /]
	<!--设置table渲染到指定ID节点-->
	[#assign renderTo="#userList"]
	[#include "/WEB-INF/pages/manage/User/_userList.ftl"]
[#else]
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Insert title here</title>
		<meta name="menu" content="AdminMenu"/>
		<meta name="heading" content="heading"/>
		[@_script /]
	</head>
	<body id="body">
		<div class="contenttitle radiusbottom0">
			<h2 id="vertical" class="form"><span>用户列表</span></h2>
		</div><!--contenttitle-->
		[#assign renderTo="#userList"]
		<div class="stepContainer" >
			<div class="tableoptions">
				<a class="radius3" href="[@c.url value='/manage/User_create.action'/]"><span>新&nbsp;&nbsp;&nbsp;&nbsp;建</span></a>
    			<button class="deletebutton radius3" title="删除所选" tableid="userListTable">删除所选</button> &nbsp;
			</div>
			<div id="userList">
				[#include "/WEB-INF/pages/manage/User/_userList.ftl"]
			</div>
		</div>
        <form id="rmUsers" action="[@c.url value='/manage/User_rm.action'][@c.param name="backUrl" value="${backUrl}"/][/@c.url]" method="post">
        	
        </form>
	</body>
	</html>
[/#if]